package cn.edu.nju.software.zp13.client.assignment9UsingJAXB.assignment4Refactoring.scoreList2.core;

import java.util.LinkedList;
import java.util.List;

import cn.edu.nju.software.zp13.client.assignment3.xmlNodeEntity.util.ScoreType;
import cn.edu.nju.software.zp13.client.assignment9UsingJAXB.assignment3Refactoring.bean.Score;
import cn.edu.nju.software.zp13.client.assignment9UsingJAXB.assignment4Refactoring.bean.CourseScoreWithManyScores;
import cn.edu.nju.software.zp13.client.assignment9UsingJAXB.assignment4Refactoring.bean.CourseScoreList;

public class CourseScoreSelector {
	public  static CourseScoreList getFailedCourseScoreList(CourseScoreList list){
		CourseScoreList failed = new CourseScoreList();
		List<CourseScoreWithManyScores> failedCourseScoreList = new LinkedList<>();
		for (CourseScoreWithManyScores courseScore : list.getCs()) {
			if (courseScore.getSt() == ScoreType.总评成绩) {
				List<Score> failedScores = new LinkedList<>();
				for (Score score : courseScore.getScore()) {
					if (score.getScore() < 60) {
						failedScores.add(score);
					}
				}
				if (failedScores.size() > 0)
					failedCourseScoreList.add(new CourseScoreWithManyScores(courseScore.getCourseId(), courseScore.getSt(),
							failedScores));
			}
		}
		failed.add(failedCourseScoreList);
		return failed;
	}
}
